using System;
using Microsoft.Web.Administration;

namespace Microsoft.Web.Management.Iis.Server
{
    /// <summary>
    /// Serves as a configuration element that can read/write configuration values
    /// for the &lt;centralBinaryLogFile&gt; configurationElement.
    /// </summary>
    internal class BinaryLogFileElement : ConfigurationElement
    {
        /********************************************************************************************
           STATIC FIELDS
         *******************************************************************************************/

        //  Names of attributes for the <centralBinaryLogFile> configuration element.
        private const string DirectoryAttribute = "directory";
        private const string EnabledAttribute = "enabled";
        private const string LocalTimeRolloverAttribute = "localTimeRollover";
        private const string PeriodAttribute = "period";
        private const string TruncateSizeAttribute = "truncateSize";

        /********************************************************************************************
           PROPERTIES
         *******************************************************************************************/

        // Properties provide read/write access to configuration.
        /// <summary>
        /// Gets or sets the directory for storring log files.
        /// </summary>
        public string Directory
        {
            get
            {
                return base[DirectoryAttribute] as String;
            }
            set
            {
                base[DirectoryAttribute] = value;
            }
        }
        /// <summary>
        /// Gets a value indicating whether central binary logging is enabled.
        /// </summary>
        public Boolean Enabled
        {
            get
            {
                return (Boolean)base[EnabledAttribute];
            }
            set
            {
                base[EnabledAttribute] = value;
            }
        }
        /// <summary>
        /// Gets or sets a value indicating whether to enable local time rollover for central binary logging.
        /// </summary>
        public Boolean LocalTimeRollover
        {
            get
            {
                return (Boolean)base[LocalTimeRolloverAttribute];
            }
            set
            {
                base[LocalTimeRolloverAttribute] = value;
            }
        }
        /// <summary>
        /// Gets or sets a value indicating the rollover period for central binary logging.
        /// </summary>
        public LoggingRolloverPeriod RolloverPeriod
        {
            get
            {
                return (LoggingRolloverPeriod)base[PeriodAttribute];
            }
            set
            {
                base[PeriodAttribute] = (Int32)value;
            }
        }
        /// <summary>
        /// Gets or sets a the size to truncate binary log files.
        /// </summary>
        public Int64 TruncateSize
        {
            get
            {
                return (Int64)base[TruncateSizeAttribute];
            }
            set
            {
                base[TruncateSizeAttribute] = value;
            }
        }

    }
}
